package cn.chen.proxy.compiler.test;

import cn.chen.proxy.compiler.InvocationHander;

import java.lang.reflect.Method;

public class TransacationHandler implements InvocationHander{

    private Object target;

    public TransacationHandler(Object target) {
        this.target = target;
    }

    @Override
    public void invoke(Object o, Method method) {
        System.out.println("Transaction start");
        try {
            method.invoke(target);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Transaction commit");
    }
}
